package com.kaifamiao.month04.day07.work;

import java.util.Arrays;
import java.util.Scanner;

public class Test03 {

    // 统计汉字个数和英文字母的个数
    public static int[] count(String str) {
        int[] countArr = new int[2];
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
                countArr[1]++;
            } else if (c >= '\u4e00' && c <= '\u9fa5') {
                countArr[0]++;
            }
        }
        return countArr;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入一段内容：");
        String str = in.next();
        System.out.println("您输入的内容 " + str + " 里面的汉字个数和英文个数分别是：" + Arrays.toString(count(str)));
    }
}
